package itsm.isperp.module.controller.app;

import javax.servlet.http.HttpServletRequest;

import itsm.isperp.framework.core.context.ContextHolder;
import itsm.isperp.framework.sequence.SequenceGenerator;
import itsm.isperp.framework.web.controller.BaseController;
import itsm.isperp.module.entity.app.AppSequence;
import itsm.isperp.module.service.app.AppSequenceService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 流水号控制器
 * 
 * @author lizx
 * @date 2013-2-16
 * @version V1.0
 */
@Controller
@RequestMapping("app/sequence")
public class AppSequenceController extends BaseController<AppSequence> {

	/**
	 * 数据字典管理服务
	 */
	@Autowired
	protected AppSequenceService appSequenceService;

	@Override
	public AppSequenceService getService() {
		return this.appSequenceService;
	}

	@Override
	public String getPageTitle() {
		return "系统流水号";
	}
	
	@RequestMapping("getSeqByTableName")
  @ResponseBody
  public String getSeqByTableName(String tableName, HttpServletRequest req) {
    SequenceGenerator sg = ContextHolder.getSpringBean("sequenceGenerator");
    String seq = sg.next(tableName);
    return seq;
  }

}
